<?php

/**
 * This is the model class for table "transaksi".
 *
 * The followings are the available columns in table 'transaksi':
 * @property integer $ID_TRANSAKSI
 * @property integer $ID_RESERVATOR
 * @property integer $ID_DETAIL_TRAVEL
 * @property string $TGL_TRANSAKSI
 * @property string $JAM_TRANSAKSI
 * @property integer $JUMLAH_PENUMPANG
 *
 * The followings are the available model relations:
 * @property DetailPerjalananTravel $iDDETAILTRAVEL
 * @property Reservator $iDRESERVATOR
 */
class Transaksi extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Transaksi the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'transaksi';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			//array('ID_TRANSAKSI', 'required'),
			array('ID_TRANSAKSI, ID_RESERVATOR, ID_DETAIL_TRAVEL, JUMLAH_PENUMPANG', 'numerical', 'integerOnly'=>true),
			array('TGL_TRANSAKSI, JAM_TRANSAKSI', 'safe'),
			array('TGL_TRANSAKSI', 'date','format'=>'yyyy-mm-dd'),
			array('JAM_TRANSAKSI', 'date','format'=>'hh:mm:ss'),
			array('JUMLAH_PENUMPANG', 'required'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID_TRANSAKSI, ID_RESERVATOR, ID_DETAIL_TRAVEL, TGL_TRANSAKSI, JAM_TRANSAKSI, JUMLAH_PENUMPANG', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'iDDETAILTRAVEL' => array(self::BELONGS_TO, 'DetailPerjalananTravel', 'ID_DETAIL_TRAVEL'),
			'iDRESERVATOR' => array(self::BELONGS_TO, 'Reservator', 'ID_RESERVATOR'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID_TRANSAKSI' => 'Id Transaksi',
			'ID_RESERVATOR' => 'Id Reservator',
			'ID_DETAIL_TRAVEL' => 'Id Detail Travel',
			'TGL_TRANSAKSI' => 'Tgl Transaksi',
			'JAM_TRANSAKSI' => 'Jam Transaksi',
			'JUMLAH_PENUMPANG' => 'Jumlah Penumpang',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID_TRANSAKSI',$this->ID_TRANSAKSI);
		$criteria->compare('ID_RESERVATOR',$this->ID_RESERVATOR);
		$criteria->compare('ID_DETAIL_TRAVEL',$this->ID_DETAIL_TRAVEL);
		$criteria->compare('TGL_TRANSAKSI',$this->TGL_TRANSAKSI,true);
		$criteria->compare('JAM_TRANSAKSI',$this->JAM_TRANSAKSI,true);
		$criteria->compare('JUMLAH_PENUMPANG',$this->JUMLAH_PENUMPANG);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}